<template>
	<view>
		<view style="height: 18upx;"></view>
		<view v-for="(item, index) in dataList" :key="index" @click="onCompanyEvent(item)" class="card-view">
			<view class="card-content">
				<view class="name-text">{{item.name}}</view>
				<view class="desc-view">
					<image src="/static/location-icon.png" class="desc-icon"></image>
					<view class="address-text">{{item.address}}</view>
				</view>
			</view>
			<uni-icons type="right" size="22upx" color="#B8ACA3"></uni-icons>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList: [],
				queryData: {
					total: 0,
					pageNo: 1,
					pageSize: 15,
				}
			};
		},
		onLoad(options) {
			this.getCorporationEnvironment()
		},
		onPullDownRefresh() {
			this.queryData.pageNo = 1
			this.getRequestList()
		},
		onReachBottom() {
			if (this.queryData.total <= this.dataList.length) return
			this.queryData.pageNo += 1
			this.getRequestList()
		},
		methods: {
			onCompanyEvent(item) {
				uni.navigateTo({
					url: `/pagesHome/VRPage/VRPage?detailId=${item.corporationEnvironmentId}`
				})
			},
			async getCorporationEnvironment() {
				const res = await uni.$api.getCorporationEnvironment()
				const list = res.data.rows || []
				this.queryData.total = res.data.totalRows
				this.dataList = this.queryData.pageNo == 1 ? list : this.dataList.concat(list)
			}
		}
	}
</script>

<style scoped lang="scss">
	.card-view {
		width: 707rpx;
		padding: 22upx;
		margin: 0 auto;
		background: #FFFFFF;
		border-radius: 14rpx;
		@extend .row-between;

		.card-content {
			width: calc(100% - 50upx);
			@extend .column;

			.name-text {
				width: 100%;
				@extend .text-dot-one;
				-webkit-line-clamp: 2;
				font-size: 33rpx;
				font-weight: 600;
				color: #2C1101;
			}

			.desc-view {
				width: 100%;
				@extend .row-start;
				font-size: 22rpx;
				font-weight: 400;
				color: #B8ACA3;
				margin-top: 14upx;

				.desc-icon {
					width: 14upx;
					height: 20upx;
					margin-right: 14upx;
				}

				.address-text {
					width: calc(100% - 16upx);
				}
			}
		}
	}

	.card-view+.card-view {
		margin-top: 18upx;
	}
</style>